import { CoolController, BaseController, QueryOp } from '@cool-midway/core';
import { Body, Inject, Post, Get, Query } from '@midwayjs/core';
import { CuserInfoEntity } from '../../entity/info'; 
import { CuserInfoService } from '../../service/info'; 

/**
 * cuser模块-用户信息
 */
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: CuserInfoEntity,
  service: CuserInfoService,
  pageQueryOp: {
    keyWordLikeFields: ['uuid', 'appId', 'promotionId'],
    fieldEq: ['status'],
  }
})
export class AdminCuserInfoController extends BaseController {
    @Inject()
    cuserInfoService: CuserInfoService;

    async page() {
      const { body } = this.baseCtx.request;
      const op = {} as QueryOp
      op.where = async (ctx) => {
        return [
          [
            { userId: ctx.admin.userId },
          ],
        ];
      }
      return this.ok(await this.service.page(body, op, this.connectionName));
    }
}
